package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingPlanUpdateDto;
import com.zzyl.dto.ProjectPlanRequestDto;
import com.zzyl.service.NursingPlanService;
import com.zzyl.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/nursing/plan")
@Api(tags = "护理计划管理")

public class NursingPlanController {
    @Autowired
    NursingPlanService nursingPlanService;

    @GetMapping
    @ApiOperation("查询所有护理计划")
    public ResponseResult<NursingPlanVo2> getAllPlan(){
        return ResponseResult.success(nursingPlanService.getAllPlan());
    }

    @PostMapping
    @ApiOperation("新增")
    public ResponseResult addNursingPlan(@RequestBody ProjectPlanRequestDto projectPlanRequestDto){
        nursingPlanService.addNursingPlan(projectPlanRequestDto);
        return ResponseResult.success();
    }

    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页码", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每页数量", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "护理姓名", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "status", value = "状态", required = false, dataType = "int", paramType = "query")
    })
    @GetMapping("/search")
    @ApiOperation("护理计划条件分页查询")
    public ResponseResult<PageResponse<NursingPlanVo3>> selectByPagePlan(
            Integer pageNum,
            Integer pageSize,
            String name,
            Integer status
    ){
        PageResponse<NursingPlanVo3> ooo = nursingPlanService.getByPagePlan(name, status, pageNum, pageSize);
        return ResponseResult.success(ooo);
    }

    /**
     * 2.4 根据id查询
     * 接口地址:/nursing/plan/{id}
     * 请求方式:GET
     */
    @GetMapping("/{id}")
    @ApiOperation("根据id查询护理计划")
    public ResponseResult<NursingPlanVo> getById(@PathVariable Long id){
        NursingPlanVo ppp = nursingPlanService.getById(id);
        return ResponseResult.success(ppp);
    }

    /**
     * 2.5 修改
     * 接口地址:/nursing/plan/{id}
     * 请求方式:PUT
     */
    @PutMapping("/{id}")
    @ApiOperation("修改护理计划")
    public ResponseResult updateNursingPlan(@PathVariable Long id,@RequestBody NursingPlanUpdateDto nursingPlanUpdateDto){
        nursingPlanService.updateNursingPlan(id, nursingPlanUpdateDto);
        return ResponseResult.success();
    }
    /**
     * 接口地址:/nursing/plan/{id}
     * 请求方式:DELETE
     * 请求参数:
     */
    @DeleteMapping("/{id}")
    @ApiOperation("删除护理计划")
    public ResponseResult deleteById(@PathVariable Long id){
        nursingPlanService.deleteById(id);
        return ResponseResult.success();
    }
    /**
     * 2.7 启用禁用
     * 接口地址:nursing/plan/{id}/status/{status}
     * 请求方式:PUT
     * 请求参数:
     */
    @PutMapping("/{id}/status/{status}")
    @ApiOperation("启用禁用护理计划")
    public ResponseResult ooo(@PathVariable Long id, @PathVariable Integer status){
        nursingPlanService.ooo(id, status);
        return ResponseResult.success();
    }
}
